package com.kmxd.ams.controller.jy;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kmxd.ams.client.jy.IAuthDetailsSvc;
import com.kmxd.ams.client.jy.dto.AuthDetailsAddDTO;
import com.kmxd.ams.client.jy.dto.AuthDetailsDeleteDTO;
import com.kmxd.ams.client.jy.dto.AuthDetailsEditDTO;
import com.kmxd.ams.client.jy.dto.AuthDetailsQueryDTO;
import com.kmxd.ams.client.jy.vo.AuthDetailsListVO;
import com.kmxd.ams.client.jy.vo.AuthDetailsVO;
import com.kmxd.ams.core.log.annotation.AutoLog;
import com.kmxd.ams.core.result.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.util.List;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 授权档案明细 前端控制器
 *
 * @author ZuoLG
 * @since 2023-11-30
 */
@RestController
@Tag(name = "授权档案明细")
@RequestMapping("/jy/authDetails")
@AllArgsConstructor
public class AuthDetailsCtl {

  private IAuthDetailsSvc authDetailsService;

  /** 分页查询 */
  @Operation(summary = "分页查询")
  @RequestMapping("/selectPage")
  @AutoLog(module = "授权档案明细", title = "分页查询")
  public R<Page<AuthDetailsListVO>> selectPage(Page reqPage, AuthDetailsQueryDTO req) {
    return R.success(authDetailsService.selectPage(reqPage, req));
  }

  /** 列表查询 */
  @Operation(summary = "列表查询")
  @RequestMapping("/selectList")
  @AutoLog(module = "授权档案明细", title = "列表查询")
  public R<List<AuthDetailsListVO>> selectList(AuthDetailsQueryDTO req) {
    return R.success(authDetailsService.selectList(req));
  }

  /** 列表查询返回Ids数据 */
  @Operation(summary = "列表查询")
  @RequestMapping("/selectByIds")
  @AutoLog(module = "授权档案明细", title = "列表查询返回Ids数据")
  public R<List<String>> selectByIds(@RequestBody AuthDetailsQueryDTO req) {
    return R.success(authDetailsService.selectByIds(req));
  }

  /** 新增 */
  @Operation(summary = "新增")
  @PostMapping("/add")
  @SaCheckPermission("jy:authDetails:add")
  @AutoLog(module = "授权档案明细", title = "新增")
  public R<Void> add(@Validated @RequestBody AuthDetailsAddDTO req) {
    authDetailsService.add(req);
    return R.success();
  }

  /** 修改 */
  @Operation(summary = "修改")
  @PostMapping("/edit")
  @SaCheckPermission("jy:authDetails:edit")
  @AutoLog(module = "授权档案明细", title = "修改")
  public R<Void> edit(@Validated @RequestBody AuthDetailsEditDTO req) {
    authDetailsService.edit(req);
    return R.success();
  }

  /** 删除 */
  @Operation(summary = "删除")
  @PostMapping("/remove")
  @SaCheckPermission("jy:authDetails:remove")
  @AutoLog(module = "授权档案明细", title = "删除")
  public R<Void> remove(@RequestBody AuthDetailsDeleteDTO req) {
    authDetailsService.remove(req);
    return R.success();
  }

  /** 查看 */
  @Operation(summary = "查看")
  @GetMapping("/view")
  @AutoLog(module = "授权档案明细", title = "查看")
  public R<AuthDetailsVO> view(@RequestParam Long id) {
    return R.success(authDetailsService.view(id));
  }
}
